/*
*
* Copyright (c) 2011 Vaulting Systems International
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal 
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
* of the Software, and to permit persons to whom the Software is furnished to do  
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all  
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE  
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.ekeyman.securesavelib.domain;

import java.io.Serializable;

public class AccessAudit  implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7021702858189715169L;
	public static String SUCCESS = "success";
	public static String NOT_FOUND = "not found";
	public static String BREACH = "breach";
	
	private long id;
	private String accessType;
	private String accessResult;
	private String resourceUri;
	private String location;
	private long version;
	
	public void setId(long id) {
		this.id = id;
	}
	public long getId() {
		return id;
	}
	public void setAccessType(String accessType) {
		this.accessType = accessType;
	}
	public String getAccessType() {
		return accessType;
	}
	public void setAccessResult(String accessResult) {
		this.accessResult = accessResult;
	}
	public String getAccessResult() {
		return accessResult;
	}

	public void setResourceUri(String resourceUri) {
		this.resourceUri = resourceUri;
	}
	public String getResourceUri() {
		return resourceUri;
	}
	public void setLocation(String location) {
		this.location = location;
	}
	public String getLocation() {
		return location;
	}
	
	public void setVersion(long version) {
		this.version = version;
	}
	public long getVersion() {
		return version;
	}
	
	@Override
	public boolean equals(Object o){
		boolean result = false;
		if (o instanceof AccessAudit){
			AccessAudit aud = (AccessAudit)o;
			if(aud.getAccessType().equalsIgnoreCase(getAccessType())
				&& aud.getAccessResult().equalsIgnoreCase(getAccessResult())
				&& aud.getResourceUri().equalsIgnoreCase(getResourceUri())
				&& aud.getLocation().equalsIgnoreCase(getLocation())) {
				result = true;
			}
		}
		return result;
	}
	
	@Override
	public int hashCode(){
		return accessType.hashCode() + accessResult.hashCode() + resourceUri.hashCode() + location.hashCode();
	}

}
